﻿using System;

class findToplitz
{
    public static bool isToplitz(int[,] matrix)
    {
        if (matrix == null) { return false; }
        int row = matrix.GetLength(0);
        int col = matrix.GetLength(1);
        for (int i = 0; i < row; i++)
        {
            if (matrix[i, i] != matrix[0, 0]) { return false; }
        }
        return true;

        for (int i = 1; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {

                int expectedValue = matrix[i - 1, j - 1];
                if (matrix[i, j] != expectedValue || matrix[i, j] != matrix[0, 0])
                {
                    return false;
                }
            }
        }
    }
    static void Main()
    {

        int[,] matrix = {
            { 1, 2, 3, 4 },
            { 5, 1, 2, 3 },
            { 9, 5, 1, 2 },
            { 2, 9, 5, 1 },
        };

        bool result = isToplitz(matrix);
        if (result) { Console.WriteLine("是托普利茨矩阵"); }
        else { Console.WriteLine("不是托普利茨矩阵"); }

    }

}



